home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / windows / editprog / newvisda.arj / FILTER.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-04-01  |  5.7 KB  |  203 lines

  1. VERSION 2.00
  2. Begin Form fFilter 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Filter"
  6.    ClientHeight    =   2370
  7.    ClientLeft      =   3390
  8.    ClientTop       =   3675
  9.    ClientWidth     =   5070
  10.    ControlBox      =   0   'False
  11.    Height          =   2835
  12.    Left            =   3300
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   2412
  17.    ScaleMode       =   0  'User
  18.    ScaleWidth      =   5160
  19.    Top             =   3300
  20.    Width           =   5250
  21.    Begin ListBox cFieldList 
  22.       BackColor       =   &H00FFFFFF&
  23.       Height          =   1395
  24.       Left            =   240
  25.       TabIndex        =   2
  26.       Tag             =   " OL"
  27.       Top             =   360
  28.       Width           =   1695
  29.    End
  30.    Begin ListBox cOpsList 
  31.       BackColor       =   &H00FFFFFF&
  32.       Height          =   1395
  33.       Left            =   2040
  34.       TabIndex        =   7
  35.       Tag             =   " OL"
  36.       Top             =   360
  37.       Width           =   960
  38.    End
  39.    Begin TextBox cExpr 
  40.       BackColor       =   &H00FFFFFF&
  41.       Height          =   287
  42.       Left            =   3120
  43.       TabIndex        =   1
  44.       Tag             =   " OL"
  45.       Top             =   360
  46.       Width           =   1811
  47.    End
  48.    Begin CommandButton OkayButton 
  49.       Caption         =   "&OK"
  50.       Default         =   -1  'True
  51.       Enabled         =   0   'False
  52.       Height          =   372
  53.       Left            =   600
  54.       TabIndex        =   4
  55.       Top             =   1919
  56.       Width           =   1691
  57.    End
  58.    Begin CommandButton CancelButton 
  59.       Cancel          =   -1  'True
  60.       Caption         =   "&Cancel"
  61.       Height          =   372
  62.       Left            =   2879
  63.       TabIndex        =   5
  64.       Top             =   1919
  65.       Width           =   1691
  66.    End
  67.    Begin Label Label1 
  68.       Alignment       =   2  'Center
  69.       AutoSize        =   -1  'True
  70.       BackColor       =   &H00C0C0C0&
  71.       Caption         =   "Do not use quotes"
  72.       Height          =   195
  73.       Left            =   3195
  74.       TabIndex        =   8
  75.       Top             =   720
  76.       Width           =   1605
  77.    End
  78.    Begin Label OpsLabel 
  79.       BackColor       =   &H00C0C0C0&
  80.       Caption         =   "Operators:"
  81.       Height          =   192
  82.       Left            =   2039
  83.       TabIndex        =   6
  84.       Top             =   120
  85.       Width           =   971
  86.    End
  87.    Begin Label FieldListLabel 
  88.       BackColor       =   &H00C0C0C0&
  89.       Caption         =   "Fields:"
  90.       Height          =   192
  91.       Left            =   240
  92.       TabIndex        =   3
  93.       Top             =   120
  94.       Width           =   1092
  95.    End
  96.    Begin Label ExprLabel 
  97.       BackColor       =   &H00C0C0C0&
  98.       Caption         =   "Value or Expression:"
  99.       Height          =   192
  100.       Left            =   3120
  101.       TabIndex        =   0
  102.       Top             =   120
  103.       Width           =   1811
  104.    End
  105. Option Explicit
  106. Dim FNotFound As Integer
  107. Sub CancelButton_Click ()
  108.   Hide
  109.   'set the flag for the dynaset/dynagrid form
  110.   gfFindFailed = True
  111. End Sub
  112. Sub cExpr_Change ()
  113.   If cFieldList <> "" And cOpsList <> "" And cExpr <> "" Then
  114.     OkayButton.Enabled = True
  115.   Else
  116.     OkayButton.Enabled = False
  117.   End If
  118. End Sub
  119. Sub cExpr_KeyPress (keyascii As Integer)
  120. If keyascii = 34 Or keyascii = 39 Then
  121. keyascii = 0
  122. End If
  123. End Sub
  124. Sub cFieldList_Click ()
  125.   If cFieldList <> "" And cOpsList <> "" And cExpr <> "" Then
  126.     OkayButton.Enabled = True
  127.   Else
  128.     OkayButton.Enabled = False
  129.   End If
  130. End Sub
  131. Sub cOpsList_Click ()
  132.   If cFieldList <> "" And cOpsList <> "" And cExpr <> "" Then
  133.     OkayButton.Enabled = True
  134.   Else
  135.     OkayButton.Enabled = False
  136.   End If
  137. End Sub
  138. Sub Form_Load ()
  139.   FNotFound = False
  140.   cOpsList.AddItem "="
  141.   cOpsList.AddItem "<>"
  142.   cOpsList.AddItem ">="
  143.   cOpsList.AddItem "<="
  144.   cOpsList.AddItem ">"
  145.   cOpsList.AddItem "<"
  146.   cOpsList.AddItem "Like"
  147. End Sub
  148. Sub Form_Paint ()
  149.   Outlines Me
  150. End Sub
  151. Sub OkayButton_Click ()
  152.    Dim i As Integer
  153.    Dim isit As Variant
  154.    On Error GoTo FindErr
  155.    FNotFound = False
  156.    SetHourGlass Me
  157.    gstFindField = cFieldList
  158.    gstFindExpr = cExpr
  159.    gstFindOp = cOpsList
  160.    isit = cExpr
  161.     'see if it's a date field
  162.         If IsDate(isit) Then
  163.         i = InStr(1, gstFindField, " ")
  164.            If i > 0 Then
  165.             FilterStr = "[" + gstFindField + "]" + " " + gstFindOp + " " + "#" + gstFindExpr + "#"
  166.            Else
  167.             FilterStr = gstFindField + " " + gstFindOp + " " + "#" + gstFindExpr + "#"
  168.            End If
  169.         Hide
  170.         GoTo Findend
  171.         'Stop'
  172.         End If
  173.    If IsNumeric(isit) Then
  174.    ' pass it, it's a number but put quotes around field name
  175.         i = InStr(1, gstFindField, " ")
  176.            If i > 0 Then
  177.             FilterStr = "[" + gstFindField + "]" + " " + gstFindOp + " " + gstFindExpr
  178.            Else
  179.             FilterStr = gstFindField + " " + gstFindOp + " " + gstFindExpr
  180.            End If
  181.    Else
  182.    ' put quotes around expression if a space is in it
  183.         i = InStr(1, gstFindField, " ")
  184.            If i > 0 Then
  185.             FilterStr = "[" + gstFindField + "]" + " " + gstFindOp + " " + Chr(34) + gstFindExpr + Chr(34)
  186.            Else
  187.             FilterStr = gstFindField + " " + gstFindOp + " " + Chr(34) + gstFindExpr + Chr(34)
  188.            End If
  189.   End If
  190.    Hide
  191.    GoTo Findend
  192. FindErr:
  193.    If Err <> EOF_ERR Then
  194.      ShowError
  195.      Resume Findend
  196.    Else
  197.      FNotFound = True
  198.      Resume Next
  199.    End If
  200. Findend:
  201.    ResetMouse Me
  202. End Sub
  203.